<template>
  <div :class="size">
    <div class="upload-container">
      <div class="image-uploader">
        <i v-if="!tempUrl" class="el-icon-plus avatar-uploader-icon" />
        <vimage class="tempimg" v-else :src="tempUrl" ></vimage>
      </div>
    </div>
  </div>
</template>

<script>
import SelectImg from '@/components/SelectImg/index';
export default {
  name: 'SingleImageUpload',
  props: {
    tempUrl: {
      type: String,
      default: ''
    },
    size: {
      type: String,
      default: 'upload-container'
    }
  },
  data() {
    return {
      drawer: false,
      url: process.env.VUE_APP_BASE_API
      // tempUrl: '',
    };
  },
  computed: {
    imageUrl() {
      return this.value;
    }
  },
  components: {
    SelectImg
  },
  methods: {
    rmImage() {
      this.emitInput('');
    },
    changeImg() {},
    emitInput(val) {
      this.$emit('input', val);
    },
    handleImageSuccess(a) {
      let tempUrl = this.url + '/' + a.msg[0];
      tempUrl = tempUrl.replace('\\', '/');
      this.emitInput(tempUrl);
    },
    handleImageError() {},
    beforeUpload() {}
  }
};
</script>

<style lang="scss" scoped>
@import '~@/styles/mixin.scss';
.upload-container {
  width: 100%;
  height: 100%;
  position: relative;
  @include clearfix;

  .image-uploader {
    width: 100%;
    height: 100%;
    float: left;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
.tempimg {
  width: 100%;
  height: 100%;
}

.upload-container_big {
  width: 100%;

  .tempimg {
    width: 300px;
    height: 150px;
  }
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
}
</style>
